const fs = require('fs')
//方式一
// let data = fs.readFileSync('./观书有感.txt')
// fs.writeFileSync('./观书有感-副本.txt', data)

//方式二 文件流式读取复制
//1.创建读取流,写入流
let rs = fs.createReadStream('./观书有感.txt')
let ws = fs.createWriteStream('./观书有感-流式副本.txt')
//2.创建监听事件
rs.on('data', (chunk) => {
  ws.write(chunk)
})
rs.on('end', () => {
  console.log('复制完成')
})
